home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’97 / Animated Icons / Source / PP Basic Starter.cp < prev    next >
Encoding:
Text File  |  1997-06-26  |  4.5 KB  |  179 lines  |  [TEXT/CWIE]

  1. // ===========================================================================
  2. //    PP Basic Starter.cp         ©1994-1997 Metrowerks Inc. All rights reserved.
  3. // ===========================================================================
  4. //
  5. //    This file contains the starter code for a basic PowerPlant application
  6.  
  7. #include "PP Basic Starter.h"
  8.  
  9. #include <LGrowZone.h>
  10. #include <LWindow.h>
  11. #include <PP_Messages.h>
  12. #include <PP_Resources.h>
  13. #include <PPobClasses.h>
  14. #include <UDrawingState.h>
  15. #include <UMemoryMgr.h>
  16. #include <URegistrar.h>
  17. #include <LEditField.h>
  18. #include "LIconSuitePane.h"
  19. #include "IconSuitePatches.h"
  20. #include <SIOUX.h>
  21. #include <LSIOUXAttachment.h>
  22.  
  23. // put declarations for resource ids (ResIDTs) here
  24.  
  25. const ResIDT    window_Sample        = 1;    // EXAMPLE
  26.  
  27.  
  28. // ===========================================================================
  29. //        • Main Program
  30. // ===========================================================================
  31.  
  32. void main(void)
  33. {
  34.  
  35.     SIOUXSettings.initializeTB = false;
  36.     SIOUXSettings.standalone = false;
  37.     SIOUXSettings.setupmenus = false;
  38.     SIOUXSettings.autocloseonquit = true;
  39.     SIOUXSettings.asktosaveonclose = false;
  40.     SIOUXSettings.showstatusline = false;
  41.  
  42.                                     // Set Debugging options
  43.     SetDebugThrow_(debugAction_Alert);
  44.     SetDebugSignal_(debugAction_Alert);
  45.  
  46.     InitializeHeap(3);                // Initialize Memory Manager
  47.                                     // Parameter is number of Master Pointer
  48.                                     //   blocks to allocate
  49.     
  50.                                     // Initialize standard Toolbox managers
  51.     UQDGlobals::InitializeToolbox(&qd);
  52.     
  53.     new LGrowZone(20000);            // Install a GrowZone function to catch
  54.                                     //    low memory situations.
  55.  
  56.     InstallAllUniversalPatches ();
  57.     
  58.     CPPStarterApp    theApp;            // replace this with your App type
  59.     theApp.Run();
  60. }
  61.  
  62.  
  63. // ---------------------------------------------------------------------------
  64. //        • CPPStarterApp             // replace this with your App type
  65. // ---------------------------------------------------------------------------
  66. //    Constructor
  67.  
  68. CPPStarterApp::CPPStarterApp()
  69. {
  70.     // Register functions to create core PowerPlant classes
  71.     
  72.     RegisterAllPPClasses();
  73.     RegisterClass_(LIconSuitePane);
  74.     RegisterClass_(LIconRefPane);
  75.  
  76.     EnterMovies ();
  77.     
  78.     AddAttachment ( new LSIOUXAttachment () );
  79. }
  80.  
  81.  
  82. // ---------------------------------------------------------------------------
  83. //        • ~CPPStarterApp            // replace this with your App type
  84. // ---------------------------------------------------------------------------
  85. //    Destructor
  86. //
  87.  
  88. CPPStarterApp::~CPPStarterApp()
  89. {
  90.     ExitMovies ();
  91. }
  92.  
  93. // ---------------------------------------------------------------------------
  94. //        • StartUp
  95. // ---------------------------------------------------------------------------
  96. //    This function lets you do something when the application starts up
  97. //    without a document. For example, you could issue your own new command.
  98.  
  99. void
  100. CPPStarterApp::StartUp()
  101. {
  102.  
  103.     ObeyCommand(cmd_New, nil);        // EXAMPLE, create a new window
  104.     
  105.     
  106.     StartIdling ();
  107.     StartRepeating();
  108. }
  109.  
  110. // ---------------------------------------------------------------------------
  111. //        • ObeyCommand
  112. // ---------------------------------------------------------------------------
  113. //    Respond to commands
  114.  
  115. Boolean
  116. CPPStarterApp::ObeyCommand(
  117.     CommandT    inCommand,
  118.     void        *ioParam)
  119. {
  120.     Boolean        cmdHandled = true;
  121.  
  122.     switch (inCommand) {
  123.     
  124.         // Deal with command messages (defined in PP_Messages.h).
  125.         // Any that you don't handle will be passed to LApplication
  126.              
  127.         case cmd_New:
  128.                                         // EXAMPLE, create a new window
  129.             LWindow        *theWindow;
  130.             theWindow = LWindow::CreateWindow(window_Sample, this);    
  131.             theWindow->Show();
  132.             break;
  133.  
  134.  
  135.  
  136.         default:
  137.             cmdHandled = LApplication::ObeyCommand(inCommand, ioParam);
  138.             break;
  139.     }
  140.     
  141.     return cmdHandled;
  142. }
  143.  
  144. // ---------------------------------------------------------------------------
  145. //        • FindCommandStatus
  146. // ---------------------------------------------------------------------------
  147. //    This function enables menu commands.
  148. //
  149.  
  150. void
  151. CPPStarterApp::FindCommandStatus(
  152.     CommandT    inCommand,
  153.     Boolean        &outEnabled,
  154.     Boolean        &outUsesMark,
  155.     Char16        &outMark,
  156.     Str255        outName)
  157. {
  158.  
  159.     switch (inCommand) {
  160.     
  161.         // Return menu item status according to command messages.
  162.         // Any that you don't handle will be passed to LApplication
  163.  
  164.         case cmd_New:                    // EXAMPLE
  165.             outEnabled = true;            // enable the New command
  166.             break;
  167.  
  168.         default:
  169.             LApplication::FindCommandStatus(inCommand, outEnabled,
  170.                                                 outUsesMark, outMark, outName);
  171.             break;
  172.     }
  173. }
  174.  
  175. void    CPPStarterApp::SpendTime(
  176.                             const EventRecord        &inMacEvent)
  177. {
  178.     MyGNEFilterRoutine ( (EventRecord*) & inMacEvent );
  179. }